package com.yh.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yh.bean.Game;
import com.yh.bean.GameClass;
import com.yh.bean.GameZone;
import com.yh.bean.Game_GameZone;
import com.yh.bean.Goods;
import com.yh.bean.GoodsClass;
import com.yh.service.GameClassService;

@Controller
public class GameClassDaoController {
	 @Autowired
	   private GameClassService gameClassServiceImpl;
	 
	 
	  @RequestMapping("showGameOneClass")
	  @ResponseBody
	   public List<GameClass> showGameClass(){
		  System.out.println("测试测试测试测试测试");
		  List<GameClass> gameClassList=gameClassServiceImpl.queryGameClass();
		  for (GameClass gameClass : gameClassList) {
			System.out.println(gameClass.getGcId()+"========"+gameClass.getGcName());
		}
		return gameClassList;
	  }
	  @RequestMapping("showOneGame")
	  @ResponseBody
	  public List<Game> showGame(int gcId){
	
		  System.out.println("================gcId=="+gcId);
		  List<Game> gameList=gameClassServiceImpl.queryGameBygId(gcId);
		  for (Game game : gameList) {
			System.out.println(game.getGameId()+"========"+game.getGameName()+"========"+game.getGc_Id());
		}
		return gameList ;
	  }
	  @RequestMapping("showGameZone")
	  @ResponseBody
	  public List<GameZone> showGameZone(int gameId){
	         
		  System.out.println("DASDASDASDASD"+gameId);
		  List<GameZone> gameZoneList=gameClassServiceImpl.queryGameZone(gameId);
		  System.out.println("游戏分区的list："+gameZoneList);
		return gameZoneList ;  
	  }
	  @RequestMapping("showGoodsClass")
	  @ResponseBody
	  public List<GoodsClass> showGoodsClass(int gzId){
		  System.out.println("gzId======="+gzId);
		  List<GoodsClass> gc=gameClassServiceImpl.queryGoodsClass(gzId);
		  for (GoodsClass goodsClass : gc) {
			System.out.println(goodsClass.getGcName()+"==============="+goodsClass.getGcId());
		}
		return gc ;		  
	  }
	  
	  @RequestMapping("showGoods")
	  @ResponseBody
	  public  Map<String,Object> showGoods(int gcId,int currentPage){
		  System.out.println("gzId======="+gcId);
		  System.out.println("currentPage======="+currentPage);
		  int defaultPage=1;
		  if(currentPage !=0)
		  {
			  defaultPage=currentPage;
		  }
		  Page page=PageHelper.startPage(defaultPage,5);
		  List<Goods> gs=gameClassServiceImpl.queryGoods(gcId);
		  
		  int pages=page.getPages();
		  Map<String,Object> map=new HashMap<String,Object>();
		  map.put("pages", pages);
		  map.put("gs", gs);
		  System.out.println("返回的数据++++++++++++++++++++："+gs);
		return map;  
	  }
	  
	  @RequestMapping("showGood")
	  @ResponseBody
	  public  Map<String,Object> showId(int gcid){
		  System.out.println("gzId======="+gcid);
		  Map<String,Object> map=new HashMap<String,Object>();
		  int id=gameClassServiceImpl.getId(gcid);
		  map.put("id", id);
		return map;  
	  }
	  @RequestMapping("showGoodS")
	  @ResponseBody
	  public Goods showGoodS(int gid){
		  Goods goods=gameClassServiceImpl.queryGoodS(gid);
		return goods ;
		  
	  }
}
